package com.china08.yxyapi.api.manage.tec.teaching.scoreport.lequestionanalysis;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.china08.yxyapi.entity.mg.scoreport.report.ExamQuesAnalyse;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.scoreport.ExamQuesAnalyseRepsository;

/**
 * 成绩分析 小题分析 - 深度分析 - 是否采纳
 * 
 */
@CrossOrigin
@RestController
public class LeQuestionAcceptController {
	@Autowired
    private ExamQuesAnalyseRepsository examQuesAnalyseRepsository;
	@RequestMapping(value = "/api_yw/manage/tec/teaching/scoreport/lequestionanalysis/knowledge/accept", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        ExamQuesAnalyse examQuesAnalyse = new ExamQuesAnalyse();
        //通过试题id查询实体类
        examQuesAnalyse = examQuesAnalyseRepsository.findById(reqModel.questionId);
        if (reqModel.accept !=null) {
        	examQuesAnalyse.setAccept(reqModel.accept);
        	examQuesAnalyseRepsository.save(examQuesAnalyse);
		}
        RespModel model = new RespModel();
        return model;
    }

    protected static class ReqModel extends YxyApiReqModel {
        // 当前选中题id
        public String questionId;
        // 是否采纳     0:不采纳   1:采纳
        public Integer accept;
    }

    protected static class RespModel extends YxyApiRespModel {
    }
}
